<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ page import="java.util.*" %>
<%@ page import="beans.*" %>
<jsp:useBean id="DatosAlumnos" scope="request" class="databeans.AlumnoDataBean" />
<% int pag = Integer.parseInt(request.getParameter("pag"));
   int conteo = DatosAlumnos.getConteoAlumnos();
   int pags; %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>EME:Listado de Alumnos</title>
        <link href="../css/estilos.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <sec:authorize ifAnyGranted="ROLE_SYSTEM">

        <table  border="0" width="100%">
            <thead>
                <tr>
                    <th >
                        <h1><img src="../images/EME2.png" width="175px"></h1>
                    </th>
                    <th >
                        <h1><img src="../images/headers/listaDeAlumnos.png"></h1>
                    </th>
                 
                </tr>
            </thead>
            <tbody>
             
                <tr>
                    <td width="200px" valign="top">
                        <div>
                            <jsp:include page="menu.jsp"/>
                        </div>
                    </td>
                    <td><center>                        
                         <table  class="tabla1" width="90%">
                                    <thead>
                                        <tr>
                                            <th>Carnet</th>
                                            <th> Nombre </th>
                                            <th> Genero </th>
                                            <th> Email </th>
                                            <th></th>
                                        </tr>

                                    </thead>
                                    <tbody>
                                    <% //Iniciar scriplet
                                    List listaAlumnos = DatosAlumnos.getListaAlumnos(pag);
                                    Iterator it = listaAlumnos.iterator();
                                    AlumnoBean alumno;
                                    while(it.hasNext()){
                                        alumno = (AlumnoBean) it.next();
                                    %>
                                    <tr>
                                        <td><%= alumno.getCarnet() %> </td>
                                        <td style="text-align: left;"><%= alumno.getNombre() %> </td>

                                        <% if(alumno.getSexo() != null)
                                        {
                                            %>

                                            <td>
                                        <%
                                            
                                            if ( alumno.getSexo().equals("M")){
                                            %>
                                            Masc.
                                            <%
                                            }else{
                                            %>
                                            Femen.
                                            <%
                                            }
                                            %>
                                         </td>
                                        
                                        <td><%= alumno.getEmail() %></td>

                                        <% }else { %>
                                        <td>&nbsp;</td>
                                        <td>&nbsp;</td>
                                        <% } %>
                                        <td><a href="detalleAlumno.jsp?carnet=<%= alumno.getCarnet() %>">
                                                Ver Detalle </a>

                                        </td>

                                        

                                    </tr>
                                    <%
                                    //Terminar el scriptlet
                                        }
                                    %>
                                    </tbody>

                                </table>
                                <br /><br />
                            <% pags = conteo/20;
                               if(conteo%20 > 0)
                                    pags++;
                               int i = 0;
                               while(i < pags) {
                                    if(i == pag){%>
                                    <%= pag %>&nbsp;|&nbsp;
                                    <%} else { %>
                                    <a href="alumnos.jsp?pag=<%=i%>"><%=i%></a>&nbsp;|&nbsp;
                            <%} // fin del if
                                    i++;
                              } // fin del while %>
                        </center>
                    </td>
                </tr>
            </tbody>
        </table>
    <div align="left">
    <jsp:include page="barrausuario.jsp"/>
    </div>
    </sec:authorize>
    </body>
</html>
